package cn.microven.mindmap.oprations;

import cn.microven.mindmap.components.node.AbstractMapNode;
import cn.microven.mindmap.struture.MindMap;
import javafx.scene.paint.Color;

public class ChangeNodeBorder implements Operation {

    private Color oldColor;

    private Color newColor;

    private AbstractMapNode node;

    public ChangeNodeBorder(Color oldColor, Color newColor, AbstractMapNode node) {
        this.oldColor = oldColor;
        this.newColor = newColor;
        this.node = node;
    }

    @Override
    public void start(boolean isRedo) {
        node.getNodeShape().setStroke(newColor);

        MindMap instance = MindMap.getInstance();
        if (!instance.isUndoing() && !instance.isRedoing()) {
            MindMap.addOperation(this);
        }
    }

    @Override
    public void undo() {
        node.getNodeShape().setStroke(oldColor);
    }
}
